#ifndef _CO_LOG_H
#define _CO_LOG_H

#include <stdint.h>
#include <stdbool.h>
#include "co_log.h"
#include "co_printf.h"
#include "plf.h"

/** @defgroup LOG_LEVEL_DEFINES 
 * @{
 */
#define LOG_LEVEL_NONE       (0)      /*!< No log output */
#define LOG_LEVEL_ERROR      (1)      /*!< Critical errors, software module can not recover on its own */
#define LOG_LEVEL_WARNING    (2)      /*!< Error conditions from which recovery measures have been taken */
#define LOG_LEVEL_INFO       (3)      /*!< Information messages which describe normal flow of events */
#define LOG_LEVEL_DEBUG      (4)      /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */
#define LOG_LEVEL_VERBOSE    (5)      /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */

#ifndef LOG_LOCAL_LEVEL
#define LOG_LOCAL_LEVEL        LOG_LEVEL_NONE
#endif

#define LOG_ERR(tag, ...)   freq_log_printf(LOG_LOCAL_LEVEL,LOG_LEVEL_ERROR,tag,__FILE__, __LINE__,##__VA_ARGS__);
#define LOG_WARN(tag, ...)  freq_log_printf(LOG_LOCAL_LEVEL,LOG_LEVEL_WARNING,tag,__FILE__, __LINE__,##__VA_ARGS__);                             
#define LOG_INFO(tag, ...)  freq_log_printf(LOG_LOCAL_LEVEL,LOG_LEVEL_INFO,tag,__FILE__, __LINE__,##__VA_ARGS__);
#define LOG_DBG(tag, ...)   freq_log_printf(LOG_LOCAL_LEVEL,LOG_LEVEL_DEBUG,tag,__FILE__, __LINE__,##__VA_ARGS__);
#define LOG_V(tag, ...)     freq_log_printf(LOG_LOCAL_LEVEL,LOG_LEVEL_VERBOSE,tag,__FILE__, __LINE__,##__VA_ARGS__);

extern bool log_enable;
extern bool log_with_file;

void freq_log_printf(uint8_t local_log_level,uint8_t log_level,uint8_t* tag  \
    ,const char* file_name,uint32_t line,const char *format, ...);


#endif  // _CO_LOG_H

